<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="com.wlcorp.forcazamis.domain.system.Staff" %>
<%@ page import="com.wlcorp.forcazamis.domain.baseinfo.Depot" %>
<%@ page import="com.wlcorp.forcazamis.sys.util.AppConstant" %>
<%@ page import="com.wlcorp.forcazamis.sys.util.SessionValue" %>
<%
	List staffList = (List)request.getAttribute("staffList");
	Depot depot = (Depot)request.getAttribute("depot");
	Staff staff = SessionValue.getInstance(request).getStaff();
%>
<html>
<head>
	<title>仓库更新</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Expires" content="0">
	<link href="${pageContext.request.contextPath}/css/css.css" rel=stylesheet>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/button_css.css" type="text/css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/form_css.css" type="text/css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/table_css.css" type="text/css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/pagetitle_css.css" type="text/css">
	<script language="javascript" src="${pageContext.request.contextPath}/script/validator.js"></script>
	<script type="text/javascript">
		function doSave(){
			if(!fieldIsNotEmpty(document.forms["depotForm"].depotName)){
				return;
			}
			document.forms["depotForm"].submit();
		}
		function goback(){
			window.location = "${pageContext.request.contextPath}/baseinfo/depotManager.do?method=getDepotList";
		}
		
		var flag = true;
		var tmpOptions = new Array();
		function managerSelect(value){
			if(value.length < 1 && flag){
				return;
			}
			var managerSelect = document.getElementById("managerId");
			var options = managerSelect.options;
			if(flag){
				for(i = 0; i < options.length;i++){
					tmpOptions[tmpOptions.length] = options[i];
				}
				flag = false;
			}
			if(value.length < 1 && !flag){
				options.length = 0;
				for(i = 0; i < tmpOptions.length;i++){
					managerSelect.add(tmpOptions[i]);
				}
				return;
			}
			var optionArray = new Array();
			for(i = 0; i < tmpOptions.length;i++){
				if(tmpOptions[i].text.indexOf(value) > -1){
					optionArray[optionArray.length] = tmpOptions[i];
				}
			}
			options.length = 0;
			for(i = 0; i < optionArray.length;i++){
				managerSelect.add(optionArray[i]);
			}
		}
	</script>
</head>
<body>
<form name="depotForm" method="POST" action="${pageContext.request.contextPath}/baseinfo/depotManager.do?method=modifyDepot">
<input type="hidden" name="depotId" value="${depot.depotId}"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="30">
	<tr> 
	  <td width="22" class="page_titlebar_head">&nbsp;</td>
	  <td class="page_titlebar_bg" width="981">仓库编辑</td>
	</tr>
</table>
<center>
<table width="80%" class="InputFrameMain" cellspacing="0" cellpadding="0" border="0" height="100">
  <tr class="InputFrameLine">
  		<td colspan="4" class="table_unfold_titlebar_small_bg">&nbsp;&nbsp;<b>仓库基本信息编辑</b></td>
  </tr>
  <tr class="InputFrameLine">
        <td class="table_label" id="depotName_TEXT">仓库名称</td>
		<td>&nbsp;<input class="input" type="text" name="depotName" value="${depot.depotName}" maxlength="20"/></td>
		<td class="table_label">仓库管理员</td>
		<td>&nbsp;<select name="managerId" style="width:100px">
				<option value="">--选择--</option>
				<%
					for(Iterator iter = staffList.iterator();iter.hasNext();){
						Staff tmpStaff = (Staff)iter.next();
				%>
				<option value="<%=tmpStaff.getStaffId()%>" <%if(null != depot.getManager() && tmpStaff.getStaffId().equals(depot.getManager().getStaffId())){out.print("selected");}%>><%=tmpStaff.getStaffName()%></option>
				<%}%>
			</select><input type="text" name="managerTxt" value="" style="width:100px" onchange="managerSelect(this.value)"/>
		</td>
  </tr>
  <tr class="InputFrameLine">
        <td class="table_label" id="depotOtherName_TEXT">仓库别名</td>
		<td>&nbsp;<input class="input" type="text" name="depotOtherName" value="${depot.depotOtherName}" maxlength="20"/></td>
		<td class="table_label" id="depotCode_TEXT">仓库编号</td>
		<td>&nbsp;<input class="input" type="text" name="depotCode" value="${depot.depotCode}" maxlength="20"/></td>
  </tr>
  <tr class="InputFrameLine">
        <td class="table_label">状态</td>
		<td>&nbsp;<select name="flag" style="width:100px">
			<option value="<%=AppConstant.DEPOT_INACTIVE%>" <%if(null != depot.getFlag() && AppConstant.DEPOT_INACTIVE == depot.getFlag().intValue()){out.print("selected");}%>>有效</option>
			<option value="<%=AppConstant.DEPOT_NOT_INACTIVE%>" <%if(null != depot.getFlag() && AppConstant.DEPOT_NOT_INACTIVE == depot.getFlag().intValue()){out.print("selected");}%>>无效</option>
		</select>
		</td>
		<td class="table_label"></td>
		<td>&nbsp;</td>
  </tr>
  <tr class="InputFrameLine">
        <td class="table_label" id="memo_TEXT">备注</td>
		<td colspan="3">&nbsp;<textarea id="memo" name="memo" cols="60" rows="4">${depot.memo}</textarea></td>
  </tr>
  <tr class="InputFrameLine">
  	
  	<td align="center" colspan="4">
  	<input type="button" class="button_save" name="save_button" value="     保存" onclick="javascript:doSave()" <%if(null != depot.getDepotId() && AppConstant.DEPOT_ID_SAMPLE == depot.getDepotId().intValue() && staff.getStaffCode().indexOf(AppConstant.ADMINISTRATOR_STAFF_CODE) < 0){out.print("style='display:none;visibility:hidden'");}%>>
  	<input type="button" class="button_common_3" name="goback_button" value="返回" onclick="javascript:history.go(-1)" class="button_save"></td>
  </tr>
</table>
</center>
</form>
${message}
</body>
</html>
